package com.example.wacoffee_user.controller;

import com.example.wacoffee_user.utils.OssUtils;
import com.example.wacoffee_user.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
public class uploadController {

    @Autowired
    private OssUtils ossUtils;

    @PostMapping("/uploadAvatar")
    public Result uploadAvatar(MultipartFile file) throws Exception {
        log.info("上传头像"+file);
        if(!file.isEmpty()){
            String url= OssUtils.uploadAvatar(file.getBytes());
            return Result.success(url);
        }
        return Result.error("上传失败");
    }


}
